package org.example.content.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.base.exception.ValidationGrops;
import org.example.content.model.dto.EditCourseDto;
import org.example.model.PageParams;
import org.example.model.PageResult;
import org.example.content.model.dto.AddCourseDto;
import org.example.content.model.dto.CourseBaseInfoDto;
import org.example.content.model.dto.QueryCourseParamsDto;
import org.example.content.model.po.CourseBase;
import org.example.content.service.CourseBaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "课程信息管理接口")
public class CourseBaseInfoController {
    @Autowired
    private CourseBaseInfoService courseBaseInfoService;
    @ApiOperation("课程分页查询接口")
    @RequestMapping("/course/list")
    public PageResult<CourseBase> list(PageParams pageParams,@RequestBody QueryCourseParamsDto queryCourseParamsDto){
       PageResult<CourseBase> pageResult=courseBaseInfoService.queryCourseBase(pageParams,queryCourseParamsDto);
        return pageResult;
    }
    @ApiOperation("新增课程")
    @PostMapping("/course")
    public CourseBaseInfoDto CreateCourseBase(@RequestBody @Validated(ValidationGrops.Inster.class) AddCourseDto addCourseDto){
        Long companyId=1232141425l;
        CourseBaseInfoDto result= courseBaseInfoService.AddCourseBase(companyId,addCourseDto);
        return result;
    }
    @ApiOperation("课程id查询数据")
    @GetMapping("/course/{courseId}")
    public CourseBaseInfoDto GetCourseBaseInfo(@PathVariable Long courseId){
     CourseBaseInfoDto courseBaseInfoDto=courseBaseInfoService.getCourseBaseInfoDto(courseId);
     return courseBaseInfoDto;
    }
    @ApiOperation("修改课程")
    @PutMapping("/course")
    public CourseBaseInfoDto modifCourseBase(@RequestBody @Validated(ValidationGrops.Update.class) EditCourseDto editCourseDto){
        Long companyId=1232141425l;
        CourseBaseInfoDto infoDto=courseBaseInfoService.updateCourseBase(companyId,editCourseDto);
        return infoDto;
    }
}
